using System;
using Server;
using System.Collections;
using Server.Network;
using Server.Mobiles;
using Server.Items;
using Server.Misc;
using Server.Commands;
using Server.Gumps;
using Server.Spells;
using Server.Spells.Mystic;

namespace Server.Gumps
{
    public class EnchantGump : Gump
    {
        private string m_Name;
        public BaseWeapon m_Item;
        public EnchantGump() : base(0, 0)
        {
            this.Closable = true;
            this.Disposable = true;
            this.Dragable = true;
            this.Resizable = false;

            AddPage(0);
            AddBackground(130, 90, 280, 180, 9270);   /// Background
            AddAlphaRegion(141, 101, 257, 158);   /// Alpha Region
            AddImageTiled(374, 100, 26, 160, 10460);   /// Celctic Bars on right
            AddItem(133, 98, 6882);   /// Top-Left Skull
            AddItem(340, 98, 6883);   /// Top-Right Skull
            AddItem(350, 250, 6881);   /// Bottom-Right Skull
            AddItem(122, 250, 6880);   /// Bottom-Left Skull
            AddHtml(165, 112, 117, 18, @"<BASEFONT COLOR=AQUA>Select Enchant</BASEFONT>", (bool)false, (bool)false);
            AddButton(165, 140, 9702, 9703, 1, GumpButtonType.Reply, 1);
            AddLabel(185, 138, 87, @"Hit Dispel");
            AddButton(165, 160, 9702, 9703, 2, GumpButtonType.Reply, 2);
            AddLabel(185, 158, 87, @"Hit Fireball");
            AddButton(165, 180, 9702, 9703, 3, GumpButtonType.Reply, 3);
            AddLabel(185, 178, 87, @"Hit Harm");
            AddButton(165, 200, 9702, 9703, 4, GumpButtonType.Reply, 4);
            AddLabel(185, 198, 87, @"Hit Lightning");
            AddButton(165, 220, 9702, 9703, 5, GumpButtonType.Reply, 5);
            AddLabel(185, 218, 87, @"Hit Magic Arrow");
        }

        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile m = state.Mobile;
           
            BaseWeapon weapon = m.Weapon as BaseWeapon;

            switch (info.ButtonID)
            {
                case 0:
                    {
                        m.CloseGump(typeof(EnchantGump));
                        break;
                    }
                case 1:
                    {
                        m.SendMessage("You added Hit Dispel to your weapon");
                        weapon.WeaponAttributes.HitDispel += 30;
                        m_Name = weapon.Name;
                        weapon.Name = "" + m_Name + " [Enchanted]";
                        m.FixedParticles(0x3728, 1, 13, 9912, 1150, 7, EffectLayer.Head);
                        m.FixedParticles(0x3779, 1, 15, 9502, 67, 7, EffectLayer.Head);
                        m.CloseGump(typeof(EnchantGump));
                        break;
                    }
                case 2:
                    {
                        m.SendMessage("You added Hit Fireball to your weapon");
                        weapon.WeaponAttributes.HitFireball += 30;
                        m.FixedParticles(0x3728, 1, 13, 9912, 1150, 7, EffectLayer.Head);
                        m.FixedParticles(0x3779, 1, 15, 9502, 67, 7, EffectLayer.Head);
                        m.CloseGump(typeof(EnchantGump));
                        break;
                    }
                case 3:
                    {
                        m.SendMessage("You added Hit Harm to your weapon");
                        weapon.WeaponAttributes.HitHarm += 30;
                        m.FixedParticles(0x3728, 1, 13, 9912, 1150, 7, EffectLayer.Head);
                        m.FixedParticles(0x3779, 1, 15, 9502, 67, 7, EffectLayer.Head);
                        m.CloseGump(typeof(EnchantGump));
                        break;
                    }
                case 4:
                    {
                        m.SendMessage("You added Hit Lightning to your weapon");
                        weapon.WeaponAttributes.HitLightning += 30;
                        m.FixedParticles(0x3728, 1, 13, 9912, 1150, 7, EffectLayer.Head);
                        m.FixedParticles(0x3779, 1, 15, 9502, 67, 7, EffectLayer.Head);
                        m.CloseGump(typeof(EnchantGump));
                        break;
                    }
                case 5:
                    {
                        m.SendMessage("You added Hit Magic Arrow to your weapon");
                        weapon.WeaponAttributes.HitMagicArrow += 30;
                        m.FixedParticles(0x3728, 1, 13, 9912, 1150, 7, EffectLayer.Head);
                        m.FixedParticles(0x3779, 1, 15, 9502, 67, 7, EffectLayer.Head);
                        m.CloseGump(typeof(EnchantGump));
                        break;
                    }
            }
        }
    }
}
                        

                  

       
    

       

      /* TimeSpan duration = TimeSpan.FromSeconds((Caster.Skills[SkillName.Mysticism].Value / 1.2) + 1.0);//needs work, just a base formula.

       Timer t = (Timer)m_Table[weapon];

       if (t != null)
           t.Stop();

       weapon.Enchanted = true;

       m_Table[weapon] = t = new ExpireTimer(weapon, duration);

       t.Start();
   }

   FinishSequence();
}

private static Hashtable m_Table = new Hashtable();

private class ExpireTimer : Timer
{
   private BaseWeapon m_Weapon;

   public ExpireTimer(BaseWeapon weapon, TimeSpan delay)
       : base(delay)
   {
       m_Weapon = weapon;
       Priority = TimerPriority.OneSecond;
   }

   protected override void OnTick()
   {
       m_Weapon.Enchanted = false;
       Effects.PlaySound(m_Weapon.GetWorldLocation(), m_Weapon.Map, 0xFA);
       m_Table.Remove(this);
   }
}

private class SoundEffectTimer : Timer
{
   private Mobile m_Mobile;

   public SoundEffectTimer(Mobile m)
       : base(TimeSpan.FromSeconds(0.75))
   {
       m_Mobile = m;
       Priority = TimerPriority.FiftyMS;
   }

   protected override void OnTick()
   {
       m_Mobile.PlaySound(0xFA);
   }
}*/
     

           
            
          


    
